package org.sunyu.sunyutest.javase1;

/**
 * @Author: Ben
 * @Date: 2019/7/12 8:02
 */
public class Test12 {

//    有一分数序列：2/1，3/2，5/3，8/5，13/8，21/13...求出这个数列的前20项之和。（10分）
    public static void main(String[] args){
        double n1 = 1;
        double n2 = 1;
        double fraction = n1/n2;
        double Sn = 0;

        for(int i=0;i<20;i++){

            double t1 = n1;
            double t2 = n2;

            n1 = t1+t2;

            n2 = t1;

            fraction = n1/n2;

            Sn += fraction;

        }
        System.out.print(Sn);
    }
}
